package ${package.Controller};

import com.Java.train.common.response.CommonResp;
import com.Java.train.business.entity.DTO.${table.entityName!}DTO;
import com.Java.train.business.req.${table.entityName!}QueryReq;
import com.Java.train.common.response.PageResp;
import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
import io.swagger.annotations.ApiOperation;
<#--import org.apache.shiro.authz.annotation.Logical;-->
<#--import org.apache.shiro.authz.annotation.RequiresPermissions;-->
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import java.util.List;
<#--import com.common.res.DataResult;-->
<#if restControllerStyle>
<#else>
    import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
    import ${superControllerClassPackage};
</#if>
/**
* @author ${author}
* @since ${date}
*/
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/admin/<#if controllerMappingHyphenStyle>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
    class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Autowired
    private ${table.serviceName} ${table.serviceName?uncap_first};


    @GetMapping("/query-list")
<#--    @RequiresPermissions("sys:${table.entityName?uncap_first}:list")-->
    @ApiOperation("${table.entityName}查询全部")
    public CommonResp< PageResp<${table.entityName}DTO>> queryList(@Valid ${table.entityName}QueryReq ${table.entityName?uncap_first}QueryReq){
        PageResp<${table.entityName}DTO> list = ${table.entityName?uncap_first}Service.queryList(${table.entityName?uncap_first}QueryReq);
        return new CommonResp<>(list);
    }

    @PostMapping("/save")
<#--    @RequiresPermissions("sys:${table.entityName?uncap_first}:update")-->
    @ApiOperation("${table.entityName}修改")
    public CommonResp<Object> update(@Valid @RequestBody ${table.entityName} ${table.entityName?uncap_first}) {
        return ${table.entityName?uncap_first}Service.modify(${table.entityName?uncap_first});
    }


    @DeleteMapping(value = "/delete/{ids}")
<#--    @RequiresPermissions("sys:${table.entityName?uncap_first}:delete")-->
    @ApiOperation("${table.entityName}删除(单个条目)")
    public CommonResp<Object> remove(@NotBlank(message = "{required}") @PathVariable String ids) {
        return ${table.entityName?uncap_first}Service.remove(ids);
    }
}
</#if>
